package iotwisp.school.system.entity;

import javax.persistence.Column;
import javax.persistence.ConstraintMode;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import iotwisp.base.orm.StringIdBaseEntity;
import org.hibernate.annotations.DynamicUpdate;

import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 *
 * @author yuxx
 *
 */
@Data
@EqualsAndHashCode(callSuper = false)
@DynamicUpdate
@Entity
@Table(name = M.TABLE_PREFIX + "city")
@SuppressWarnings("serial")
public class City extends StringIdBaseEntity {

	/**
	 * 名称
	 */
	@Column(name = "name", length = 32)
	private String name;

	/**
	 * 代码
	 */
	@Column(name = "code", length = 16)
	private String code;

	/**
	 * 所属省份
	 */
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "province_id", foreignKey = @ForeignKey(name = "none", value = ConstraintMode.NO_CONSTRAINT))
	private Province province;

}
